<!--  -->
<template>
  <div>
    <cu-custom
      :bgImage="bgImage"
      :needBack="true"
      bgColor="bgNormal"
      topTitle="评审结果"
      titleClass="commTitleWhite"
      backIconColor="#fff"
    ></cu-custom>
    <view class="content">
      <scroll-view
        class="scroll_content"
        scroll-y
        :style="{ height: scorllContentHeight }"
        v-if="noticeList.length > 0"
        @scrolltolower="loadMore"
      >
        <view style="padding: 0 30rpx">
          <view
            class="notice_list"
            v-for="(item, index) in noticeList"
            :key="index"
            @click="toDeatil(item)"
          >
            <view class="">
              {{ item.title }}
            </view>
            <view class=""> 发布时间：{{ item.createTime }} </view>
          </view>
        </view>

        <u-loadmore :status="status" :load-text="loadText"></u-loadmore>
      </scroll-view>
			<u-empty v-else text="暂无数据~"></u-empty>
    </view>
  </div>
</template>

<script>
import { getIndusnotificationManagementList } from "@/api/home";
export default {
  data() {
    return {
      scorllContentHeight: "", // 页面滚动高度
      noticeList: [
        {
          title:
            "标题内容标题内容标题内容标题内容标题内容标题内容标题内容标题内容标题内容标题内容标题内容",
          time: "2023-04-08  12:05:30",
        },
        {
          title: "标题内容",
          time: "2023-04-08  12:05:30",
        },
        {
          title: "标题内容",
          time: "2023-04-08  12:05:30",
        },
        {
          title: "标题内容",
          time: "2023-04-08  12:05:30",
        },
        {
          title: "标题内容",
          time: "2023-04-08  12:05:30",
        },
        {
          title: "标题内容",
          time: "2023-04-08  12:05:30",
        },
        {
          title: "标题内容",
          time: "2023-04-08  12:05:30",
        },
        {
          title: "标题内容",
          time: "2023-04-08  12:05:30",
        },
        {
          title: "标题内容",
          time: "2023-04-08  12:05:30",
        },
        {
          title: "标题内容",
          time: "2023-04-08  12:05:30",
        },
        {
          title: "标题内容",
          time: "2023-04-08  12:05:30",
        },
        {
          title: "标题内容",
          time: "2023-04-08  12:05:30",
        },
      ],
      form: {
        size: 10,
        current: 1,
        type: "3",
      },
      total: 0,
      loadText: {
        loadmore: "加载更多",
        loading: "加载中",
        nomore: "没有更多了",
      },
      status: "loadmore",
    };
  },
  onShow() {
    this.getHeight();
    this.getList();
  },
  methods: {
    // 动态计算滚动高度
    getHeight() {
      this.scorllContentHeight = `calc(100vh - ${this.CustomBar}px - 24rpx - 20rpx)`;
    },
    getList() {
      getIndusnotificationManagementList(this.form).then((res) => {
        if (res.code == 200) {
          this.total = res.data.total;
          // console.log("res===", res);
          if (res.data.total > 10) {
            this.noticeList = this.noticeList.concat(res.data.records); //合并数组
            console.log(this.noticeList);
          } else {
            this.noticeList = res.data.records;
            this.status = "nomore";
          }
        }
      });
    },
    // 加载更多
    loadMore() {
      console.log("到底了");
      if (this.total > this.form.current * this.form.size) {
        this.status = "loading";
        this.form.current++;
        this.getList();
      } else {
        this.status = "nomore";
      }
    },
    // 详情
    toDeatil(data) {
      uni.navigateTo({
        url: `./detail?id=${data.id}`,
      });
    },
  },
  components: {},
};
</script>
<style lang="scss" scoped>
.content {
  margin-top: 24rpx;

  background: #f2f2f2;

  .scroll_content {
    // width: calc(100% - 60rpx) !important;
    // padding: 0 30rpx;
    .notice_list {
      padding: 41rpx 30rpx 45rpx 40rpx;
      background: #fff;
      border-radius: 8rpx;

      &:nth-child(n + 2) {
        margin-top: 17rpx;
      }

      &:last-child {
        margin-bottom: 10rpx;
      }

      view:first-child {
        font-size: 28rpx;
        color: #333;
        height: 40rpx;
        line-height: 40rpx;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
      }

      view:last-child {
        font-size: 24rpx;
        color: #999;
        margin-top: 25rpx;
      }
    }
  }
}

::v-deep {
  .u-load-more-wrap {
    margin: 10rpx 0 !important;
  }
}
</style>